<template>
  <div class="home">
  <div>
    <p>
      RH SSO URL  : <input name="authAddr" v-model="user.authAddr"  style="width:600px ;"/>
    </p>
    <p>
      Service URL : <input name="APIendpoint" v-model="user.apiEndpoint" style="width:600px ;" />
    </p>
  </div>
  <div>
    <p>
      SSO URL value: {{user.authAddr}}
    </p>
    <p>
      Service URL  : {{user.apiEndpoint}}
    </p>
    <button @click="changeVite">change init args</button>
  </div>
    <HelloWorld msg="Welcome to Your Vue.js App"/>
  </div>

</template>

<script>
import { ref, onMounted, reactive,getCurrentInstance } from 'vue'
// @ is an alias to /src
import HelloWorld from '../components/HelloWorld.vue'

const {
    proxy
}=getCurrentInstance();

export default {
  name: 'HomeView',
  components: {
    HelloWorld
  },
  data(){
        return{
            user:{
              authAddr:"",
              apiEndpoint:""
            }
        }
    },
    mounted(){
      this.user.authAddr = proxy.appConfig.AUTHADDR;
      this.user.apiEndpoint = proxy.appConfig.APIENDPOINT
    },
    methods:{
        changeVite(){
          //import.meta.env.VITE_URL_USERMANAGE=this.user.apiEndpoint;
          //import.meta.env.VITE_URL_KEYCLOAKSERVER = this.user.authAddr;

          proxy.appConfig.AUTHADDR=this.user.authAddr;
          proxy.appConfig.APIENDPOINT=this.user.apiEndpoint;
          alert("初始化参数的值已经修改完成");
        }
    }

  
}

//const ssoUrl = ref('');

</script>
<style>
.login{
    /* 表单外容器样式 */
    background:rgb(245, 240, 240);
    height:320px;
    width:450px;
    margin:100px auto;
    border-radius: 20px;
    /* 表单位置水平垂直居中 */
    display:flex;
    justify-content: center;
    align-items: center;
}
</style>